<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/3/13
  Time: 11:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
    <title>登陆</title>
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" title="" rel="stylesheet" />
    <link title="orange" href="${pageContext.request.contextPath}/css/login.css" rel="stylesheet" type="text/css"/>


</head>

<body>

<div style="height:1px;"></div>
<div class="login">
    <header>
        <h1>后台登陆</h1>
    </header>
    <div class="sr">

            <div class="name">
                <label>
                    <i class="sublist-icon glyphicon glyphicon-user"></i>
                </label>
                <input type="text" id="mname" name="mname" placeholder="这里输入登录名" class="name_inp">
            </div>
            <div class="name">
                <label>
                    <i class="sublist-icon glyphicon glyphicon-pencil"></i>
                </label>
                <input type="password" id="password" name="password" placeholder="这里输入登录密码" class="name_inp">
            </div>
            <button class="dl" onclick="requestJson()">登陆</button>
           </div>
</div>
<script src="${pageContext.request.contextPath}/js/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
    function requestJson(){

        var mname =$("#mname").val();//#是id选择器
        var pwd =$("#password").val();
        if(mname==""){
            alert("账号不能为空！");
            return false;
        }
        else if(pwd==""){
            alert("密码不能为空！");
            return false;
        }
        else
        {
            $.ajax({
                type:'post',
                url:'${pageContext.request.contextPath}/admin/login_verify',
                dataType:"json",//注意使用的是打他dataType，而不是Content-Type
                async: true,
                data:{mname:mname,password:pwd},
                success:function(data){
                    if (data==1){

                        window.location.href ="${pageContext.request.contextPath}/admin/index";
                    }
                    else if (data==2){

                        window.location.href ="${pageContext.request.contextPath}/admin/admin2";

                    }
                    else if (data==3){

                        window.location.href ="${pageContext.request.contextPath}/admin/admin1";
                    }
                    else if (data==0){
                        alert("账号或密码出现错误，请重新登录！")

                    }
                    else {
                        alert("对不起，服务器出现异常，请稍后再试！")
                    }
                }
            });
        }
    }
</script>
</body>

</html>

